﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class ChiTietDichVu : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            dataBind();
        }
    }

    public void dataBind()
    {
        int MaDV = int.Parse(Session["MaDV"].ToString());
        string connStr = System.Configuration.ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
        SqlConnection conn = new SqlConnection(connStr);
        conn.Open();
        SqlCommand com = new SqlCommand();
        com.Connection = conn;
        com.CommandText = "sp_ChiTietDichVu";
        com.CommandType = CommandType.StoredProcedure;
        com.Parameters.AddWithValue("@MaDV", MaDV);
        SqlDataReader dr = com.ExecuteReader();
        if (dr.HasRows)
        {
            dr.Read();
            hinhanh.ImageUrl = dr["ThumbNail"].ToString();
            banner_tendichvu.InnerText = dr["TenDV"].ToString()+" ("+dr["LinhVuc"].ToString()+")";
            detail_mota.InnerText = dr["MoTa"].ToString();
            string giamgia = dr["ThongTinGiamGia"].ToString();
            string[] mang_giamgia = giamgia.Split('.');
            for (int i = 0; i < mang_giamgia.Length; i++)
            {
                if ((mang_giamgia[i].Contains("Giảm") && mang_giamgia[i].Contains("%")) || (mang_giamgia[i].Contains("Giảm") && mang_giamgia[i].Contains("nếu khách hàng")))
                {
                    mang_giamgia[i] = "<li style='position:static;display:list-item;color:red;font-weight:bold;'>" + mang_giamgia[i] + "</li>";
                }
                else 
                {
                    mang_giamgia[i] = "<li style='position:static;display:list-item;color:#660033'>" + mang_giamgia[i] + "</li>";
                }
                ulThongtinkhuyenmai.InnerHtml = ulThongtinkhuyenmai.InnerHtml + mang_giamgia[i];
            }
            DiaChi.InnerHtml=DiaChi.InnerHtml+dr["DiaChi"].ToString();
            Quan.InnerHtml=Quan.InnerHtml+dr["Quan"].ToString();
			DT.InnerHtml=DT.InnerHtml+dr["DT"].ToString();


        }

    }
}